package de.hft.st.algodat.ctt.model;

public class Timeslot {
	private int day;
	private int period;
	private Room room;
	private int tsID;
	private Course assigned = null;
	private boolean isAssigned = false;
	
	public Timeslot(int day, int period) {
		this.day = day;
		this.period = period;
	}

	public Timeslot(int day, int period, int tsID, Room room) {
		this.day = day;
		this.period = period;
		this.tsID = tsID;
		this.room = room;
	}

	public int getTsID() {
		return tsID;
	}

	public int getDay() {
		return day;
	}

	public int getPeriod() {
		return period;
	}

	public Course getAssigned() {
		return assigned;
	}

	public void setAssigned(Course assigned) {
		this.assigned = assigned;
		this.isAssigned = true;
	}

	public boolean isAssigned() {
//		return (this.assigned != null);
		return this.isAssigned;
	}

	public Room getRoom() {
		return this.room;
	}

	@Override
	public String toString() {
		// <CourseID> <RoomID> <Day> <Day_Period>
		if (null != this.assigned) {
			StringBuffer toStr = new StringBuffer();
			toStr.append(this.assigned.getId());
			toStr.append(" " + this.getRoom().getId() + " " + (this.day-1) + " " + (this.period-1));
			return toStr.toString() + "\n";
		}
		return "";
	}
	
}
